//
//  ZLCourseLearningDetailCell.m
//  ZLExamination
//
//  Created by Zheng on 2017/8/15.
//  Copyright © 2017年 Zheng. All rights reserved.
//

#import "ZLCourseLearningDetailCell.h"
#import "ZLCourseLerningDetailModel.h"

@implementation ZLCourseLearningDetailCell

- (void)setModel:(ZLCourseLerningDetailListModel *)model {
    _model = model;
    
    _titleLbl.text = _model.title;
    
    if (_model.is_read.integerValue == 1) {
        //锁定
        _stateLbl.text = @"未解锁";
        _stateLbl.textColor = [UIColor lightGrayColor];
        _iconImgv.hidden = NO;
    } else {
        //未锁定
        _stateLbl.text = @"练习";
        _stateLbl.textColor = kMY_BLUE_COLOR;
        _iconImgv.hidden = YES;
    }
    
}

#pragma mark - 初始化方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (!self) return nil;

    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    [self.contentView addSubview:self.titleLbl];
    [self.contentView addSubview:self.stateLbl];
    [self.contentView addSubview:self.iconImgv];
    
    [_titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.centerY.equalTo(self);
    }];
    
    [_stateLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.centerY.equalTo(self);
    }];
    
    [_iconImgv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_stateLbl.mas_left).offset(-5);
        make.centerY.equalTo(self);
    }];

    return self;
}


- (UILabel *)stateLbl {
    if (!_stateLbl) {
        _stateLbl = [[UILabel alloc] init];
        _stateLbl.font = kMyFont(11);
    }
    return _stateLbl;
}

- (UIImageView *)iconImgv {
    if (!_iconImgv) {
        _iconImgv = [[UIImageView alloc] init];
        _iconImgv.backgroundColor = kMY_BLUE_COLOR;
        _iconImgv.hidden = YES;
    }
    return _iconImgv;
}

- (UILabel *)titleLbl {
    if (!_titleLbl) {
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.font = kMyFont(14);
    }
    return _titleLbl;
}



@end
